/*
 * 易族智汇（北京）科技有限公司 版权所有。
 * 未经许可，您不得使用此文件。
 * 官方地址：www.javamall.com.cn
 */
package com.enation.app.javashop.core.client.feignimpl.distribution;

import com.enation.app.javashop.client.distribution.DistributionOrderClient;
import com.enation.app.javashop.core.client.fallback.distribution.DistributionOrderClientFallbackFactory;
import com.enation.app.javashop.core.handler.FeignConfiguration;
import com.enation.app.javashop.model.distribution.dos.DistributionOrderDO;
import com.enation.app.javashop.model.trade.order.dos.OrderDO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;


/**
 * 分销Order client
 *
 * @author Chopper
 * @version v1.0
 * @since v6.1
 * 2016年10月2日 下午5:24:14
 */
@FeignClient(name = "distribution-service", fallbackFactory = DistributionOrderClientFallbackFactory.class,configuration = {FeignConfiguration.class})
public interface DistributionOrderClientFeignImpl extends DistributionOrderClient {

    /**
     * 根据sn获得分销商订单详情
     *
     * @param orderSn 订单编号
     * @return FxOrderDO
     */
    @Override
    @RequestMapping(value = "/client/distribution/order/get", method = RequestMethod.POST)
    DistributionOrderDO getModelByOrderSn(@RequestParam("order_sn") String orderSn);

    /**
     * 保存一条数据
     *
     * @param distributionOrderDO
     * @return
     */
    @Override
    @RequestMapping(value = "/client/distribution/order/add", method = RequestMethod.POST)
    DistributionOrderDO add(@RequestBody DistributionOrderDO distributionOrderDO);

    /**
     * 通过订单id，计算出各个级别的返利金额并保存到数据库
     *
     * @param orderSn 订单编号
     * @return 计算结果 true 成功， false 失败
     */
    @Override
    @RequestMapping(value = "/client/distribution/order/cal", method = RequestMethod.POST)
    boolean calCommission(@RequestParam("order_sn") String orderSn);

    /**
     * 根据购买人增加上级人员订单数量
     *
     * @param buyMemberId 购买人会员id
     */
    @Override
    @RequestMapping(value = "/client/distribution/order/num/add", method = RequestMethod.POST)
    void addOrderNum(@RequestParam("buy_member_id") Long buyMemberId);


    /**
     * 计算退款时需要退的返利金额
     *
     * @param orderSn 订单sn
     * @param price   退款金额
     * @return 计算结果 true 成功， false 失败
     */
    @Override
    @RequestMapping(value = "/client/distribution/order/num/cal/return", method = RequestMethod.POST)
    boolean calReturnCommission(@RequestParam("order_sn") String orderSn, @RequestParam("price") double price);

    /**
     * 结算订单
     *
     * @param order
     */
    @Override
    @RequestMapping(value = "/client/distribution/order/confirm", method = RequestMethod.POST)
    void confirm(@RequestBody OrderDO order);
}
